#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,xin,i,j;
	char c;
	cin>>a>>b>>c>>xin;
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			if(xin==0)
			{
				if(i==1||i==a)
				cout<<c;
				else
				j==1||j==b?cout<<c:cout<<" ";
			}
			else
			cout<<c;
			if(j==b) cout<<endl;
		}
	}
    return 0;
}

